package com.iflytek.ci.security;

import com.iflytek.iframework.orm.hibernate.HibernateEntityDao;
import com.iflytek.jsec.cac.domain.*;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * 假的获取权限服务
 * 
 * @author quansun
 * @version $Id: MockSecurityManager.java 983 2013-03-25 07:44:02Z quansun $
 */
public class MockSecurityManager extends HibernateEntityDao<Object> implements
        BusinessSecurityManager {

    /**
     * 
     * @see com.iflytek.common.security.BusinessSecurityManager#getCurrentUser(javax.servlet.http.HttpSession)
     * @author scrum
     * @created 2013-6-23 下午04:07:45
     * @lastModified
     * @history
     */
    public User getCurrentUser(HttpSession session) {
        // return getUser("131100000000","衡水市公安局");
        // return getUser("131121000000","枣强县公安局");
        // return getUser("130700000000" ,"张家口市");
        return getUser("210000000000", "辽宁省公安厅");
    }

    /**
     * 
     *  ｛说明该函数的含义和作用，如果函数较为复杂，请详细说明｝
     *  @param orgCode
     *  @param orgName
     *  @return
     *  @author scrum
     *  @created 2013-6-23 下午04:07:55
     *  @lastModified       
     *  @history
     */
    private User getUser(String orgCode, String orgName) {
        User user = new User();
        user.setId("1");
        user.setLoginName("sadmin");
        user.setName("管理员");
        user.setOrgId(orgCode);
        user.setOrgName("辽宁省公安厅");
        user.setSfzh("");
        Organization org = new Organization();
        org.setName("辽宁省公安厅");
        org.setFullName("辽宁省公安厅");
        org.setCode(orgCode);
        user.setOrganization(org);

        Region region = new Region();
        region.setCode(orgCode);
        region.setName("辽宁省公安厅");

        user.setRegion(region);

        return user;
    }

    /**
     * 
     *  @see com.iflytek.common.security.BusinessSecurityManager#getRoleMcsOfUser(com.iflytek.jsec.cac.domain.User)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:00
     *  @lastModified      
     *  @history
     */
    public String getRoleMcsOfUser(User user) {
        return "ROLE_PORTAL_SLV,ROLE_CLBK_AD";
    }

    /**
     * 
     *  @see com.iflytek.common.security.BusinessSecurityManager#getUserByLoginName(String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:03
     *  @lastModified
     *  @history
     */
    public User getUserByLoginName(String userLoginName) {
        return getUser("210000000000", "辽宁省公安厅");
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getUsers(String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:07
     *  @lastModified
     *  @history
     */
    public List<User> getUsers(String orgCode) {
        List<User> user = new ArrayList<User>();

        User u1 = new User();
        u1.setId("1");
        u1.setLoginName("sadmin");
        u1.setName("管理员");
        u1.setOrgId("520000000000");
        u1.setOrgName("辽宁省公安厅");
        u1.setSfzh("");
        Organization org = new Organization();
        org.setName("辽宁省公安厅");
        org.setFullName("辽宁省公安厅");
        org.setCode("210000000000");
        u1.setOrganization(org);

        user.add(u1);

        User u2 = new User();
        u2.setId("2");
        u2.setLoginName("130122197906252218");
        u2.setName("辽宁省公安厅");
        u2.setOrgId("5210000000000");
        u2.setOrgName("辽宁省公安厅");
        u2.setSfzh("");
        Organization org2 = new Organization();
        org2.setName("辽宁省公安厅");
        org2.setFullName("辽宁省公安厅");
        org2.setCode("210000000000");
        u2.setOrganization(org);

        user.add(u2);

        return user;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getFirstMenhuOfCurrentUser()
     *  @author scrum
     *  @created 2013-6-23 下午04:08:12
     *  @lastModified
     *  @history
     */
    public List<Authority> getFirstMenhuOfCurrentUser() {
        List<Authority> menus = new ArrayList<Authority>();
        Authority a1 = new Authority();
        a1.setDisplayName("平台首页");
        a1.setMenuUrl("#");
        menus.add(a1);

        Authority a2 = new Authority();
        a2.setDisplayName("重点人员管控");
        a2.setMenuUrl("#");
        menus.add(a2);

        Authority a3 = new Authority();
        a3.setDisplayName("重大事件预警");
        a3.setMenuUrl("#");
        menus.add(a3);

        Authority a4 = new Authority();
        a4.setDisplayName("辅助决策分析");
        a4.setMenuUrl("#");
        menus.add(a4);

        Authority a5 = new Authority();
        a5.setDisplayName("网上作战导侦");
        a5.setMenuUrl("#");
        menus.add(a5);

        Authority a6 = new Authority();
        a6.setDisplayName("信息智能检索");
        a6.setMenuUrl("#");
        menus.add(a6);

        Authority a7 = new Authority();
        a7.setDisplayName("系统运行监控");
        a7.setMenuUrl("#");
        menus.add(a7);

        Authority a8 = new Authority();
        a8.setDisplayName("信息发布管理");
        a8.setMenuUrl("#");
        menus.add(a8);

        Authority a9 = new Authority();
        a9.setDisplayName("系统配置管理");
        a9.setMenuUrl("#");
        menus.add(a9);

        return menus;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getFrameSetWebContext()
     *  @author scrum
     *  @created 2013-6-23 下午04:08:17
     *  @lastModified
     *  @history
     */
    public String getFrameSetWebContext() {
        // TODO Auto-generated method stub
        return null;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getCurrentUserInfo(javax.servlet.http.HttpSession)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:20
     *  @lastModified
     *  @history
     */
    public UserInfo getCurrentUserInfo(HttpSession session) {
        UserInfo user = new UserInfo();
        user.setSfzh("130122197906252218");
        return user;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getUserInfoByLoginName(String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:24
     *  @lastModified
     *  @history
     */
    public UserInfo getUserInfoByLoginName(String userLoginName) {
        UserInfo user = new UserInfo();
        user.setSfzh("130122197906252218");
        return user;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getUserBySfzh(String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:27
     *  @lastModified
     *  @history
     */
    public User getUserBySfzh(String sfzh) {
        User user = new User();
        user.setLoginName("sadmin");
        return user;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#isUserHasAuth(com.iflytek.jsec.cac.domain.User, String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:30
     *  @lastModified
     *  @history
     */
    public boolean isUserHasAuth(User user, String authName) {
        // TODO Auto-generated method stub
        return true;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#isUserHasRole(com.iflytek.jsec.cac.domain.User, String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:34
     *  @lastModified
     *  @history
     */
    public boolean isUserHasRole(User user, String roleId) {
        // TODO Auto-generated method stub
        return false;
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getCurrentUser()
     *  @author scrum
     *  @created 2013-6-23 下午04:08:38
     *  @lastModified
     *  @history
     */
    public User getCurrentUser() {
        return getUser("210000000000", "辽宁省公安厅");
    }

    /**
     *
     *  @see com.iflytek.common.security.BusinessSecurityManager#getMenuByMenuName(String)
     *  @author scrum
     *  @created 2013-6-23 下午04:08:41
     *  @lastModified      
     *  @history
     */
    public String getMenuByMenuName(String menuName) {
        return "";
    }
}
